package practise;

import org.junit.Test;

import java.lang.reflect.Constructor;
import java.util.Scanner;

public class five {
    public static void main(String[] args) {

    }
    @Test
    public void TestA(){
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入类的全名:");
        String string = scanner.nextLine();
        try {
            Class c = Class.forName(string);
            Constructor constructor = c.getConstructor();
            A s = (A)constructor.newInstance();
            s.showString();
        }catch (Exception e) {

        }
    }
}

class A {
    String string = "hello world" ;
    public void showString() {
        System.out.println(string);
    }
}